package com.jane.addressbook.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Login extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1174598640224688485L;
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req,resp);
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		if (req.getParameter("uid").equals("123")
				&& req.getParameter("upwd").equals("123")) {
			req.getSession().setAttribute("uid", req.getParameter("uid"));
			resp.sendRedirect("list");
		}else{
			resp.sendRedirect("index.jsp");
		}
	}

}
